<?php
// app/Model/User.php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
    public $name = 'User';
    public $validate = array(
        'username' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Se requiere un nombre de usuario'
            )
        ),
        'password' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Se requiere una contrase&ntilde;a'
            )
        )//,
       // 'role' => array(
       //     'valid' => array(
       //         'rule' => array('inList', array('admin', 'author')),
        //        'message' => 'Please enter a valid role',
       //         'allowEmpty' => false
       //     )
       // )
    );
	
	public function beforeSave() {
    if (isset($this->data[$this->alias]['password'])) {
    	
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    }
    return true;
}
}